package metrics;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import summarizer.newversion.ClusterSummarizer;
import summarizer.newversion.FileSummarizer;
import summarizer.newversion.Summarizer;
import thesis.FSModule;
import thesis.InfoUnit;
import thesis.DataObject;
import thesis.Summary;

public class QualityEvaluate {
	public static void evaluate(ArrayList<Summarizer> summarizers,
			final HashMap<Long, DataObject> memoryTweets,
			final ArrayList<InfoUnit> infoUnits, final double[][] probs,
			int dimSize) {
		final int numRepeat = 5;
		for (int M = 5; M <= 50; M += 5) {
			// for (int M = 10; M <= 200; M += 19) {
			ArrayList<Summary[]> multiSummary = new ArrayList<Summary[]>();
			for (int i = 0; i < summarizers.size(); i++) {
				if (FSModule.DEBUG) {
					System.out.println("\n-------Start " + summarizers.get(i)
							+ "--------");
				}
				int repeat = summarizers.get(i).rndAlgo ? numRepeat : 1;
				Summary[] sums = new Summary[repeat];
				for (int r = 0; r < repeat; r++) {
					sums[r] = summarizers.get(i).computeSummary(M, 1,
							(HashMap<Long, DataObject>) memoryTweets.clone(),
							dimSize);
				}
				multiSummary.add(sums);
			}
			if (M == 200) {
				try {
					FileSummarizer.recordSummary(multiSummary.get(0)[0]);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			Evaluate.evaluate(M, multiSummary, summarizers,
					memoryTweets.values(), infoUnits, probs);
		}
	}
}
